package {
	
	import mz.behaveas.model.ducktype.Duck;
	import flash.display.Sprite;
	import flash.events.Event;
	
/**
 * @author maxim.zaks@gmail.com
 */
public const DuckSpec : * = {
		description : "Specification for Duck class.",
		expectations : [
			{
				description : "Duck is null and equals to null",
				behaviour : function():*{
					return new Duck(null).equals(null);
				},
				shouldEqual : true
			},
			{
				description : "Duck is null and equal to 1, because duck is a subset",
				behaviour : function():*{
					return new Duck(null).equals(1);
				},
				shouldEqual : true
			},
			{
				description : "Duck is {_type_:int} and equals to new int()",
				behaviour : function():*{
					return new Duck({_type_:int}).equals(new int());
				},
				shouldEqual : true
			},
			{
				description : "Duck is {_type_:int} and equals to 3",
				behaviour : function():*{
					return new Duck({_type_:int}).equals(3);
				},
				shouldEqual : true
			},
			{
				description : "Duck is {_type_:int} and equals to '3'",
				behaviour : function():*{
					return new Duck({_type_:int}).equals('3');
				},
				shouldEqual : false
			},
			{
				description : "Duck is {_type_:int,toString:'3'} and equals to 3",
				behaviour : function():*{
					return new Duck({_type_:int,toString:'3'}).equals(3);
				},
				shouldEqual : true
			},
			{
				description : "Duck is {_type_:Array, length:0} and equals to []",
				behaviour : function():*{
					return new Duck({_type_:Array, length:0}).equals([]);
				},
				shouldEqual : true
			},
			{
				description : "Duck is {_type_:Array, length:1} and equals to [1]",
				behaviour : function():*{
					return new Duck({_type_:Array, length:1}).equals([1]);
				},
				shouldEqual : true
			},
			{
				description : "Duck is {_type_:Array, length:0} and equals to [1]",
				behaviour : function():*{
					return new Duck({_type_:Array, length:0}).equals([1]);
				},
				shouldEqual : false
			},
			{
				description : "Duck is [1] and equals to [1]",
				behaviour : function():*{
					return new Duck([1]).equals([1]);
				},
				shouldEqual : true
			},
			{
				description : "Duck is {0:1} and equals to [1]",
				behaviour : function():*{
					return new Duck({0:1}).equals([1]);
				},
				shouldEqual : true
			},
			{
				description : "Duck is {0:1} and equals to mixed array 1,b:2",
				behaviour : function():*{
					var a : Array = [1];
					a["b"] = 2;
					return new Duck({0:1}).equals(a);
				},
				shouldEqual : true
			},
			{
				description : "Duck is {0:1,b:2} and equals to mixed array 1,b:2",
				behaviour : function():*{
					var a : Array = [1];
					a["b"] = 2;
					return new Duck({0:1,b:2}).equals(a);
				},
				shouldEqual : true
			},
			{
				description : "Duck is {0:1,b:1} and equals to mixed array 1,b:2",
				behaviour : function():*{
					var a : Array = [1];
					a["b"] = 2;
					return new Duck({0:1,b:1}).equals(a);
				},
				shouldEqual : false
			},
			{
				description : "Duck is {1:[1,2,3]} and equals to 3d array [1,[1,2,3],'b']",
				behaviour : function():*{
					var a : Array = [1,[1,2,3],'b'];
					return new Duck({1:[1,2,3]}).equals(a);
				},
				shouldEqual : true
			},
			{
				description : "Duck is {0:[1,2,3]} and equals to 3d array [1,[1,2,3],'b']",
				behaviour : function():*{
					var a : Array = [1,[1,2,3],'b'];
					return new Duck({0:[1,2,3]}).equals(a);
				},
				shouldEqual : false
			},
			{
				description : "Duck is {_type_:Sprite} and equals to new Sprite()",
				behaviour : function():*{
					var s : Sprite = new Sprite();
					return new Duck({_type_:Sprite}).equals(s);
				},
				shouldEqual : true
			},
			{
				description : "Duck is {_type_:Sprite, numChildren:1, parent:null} and equals to main sprite with one child",
				behaviour : function():*{
					var s : Sprite = new Sprite();
					var s1 : Sprite = new Sprite();
					s.addChild(s1);
					return new Duck({_type_:Sprite, numChildren:1, parent:null}).equals(s);
				},
				shouldEqual : true
			},
			{
				description : "Duck is {_type_:Sprite, numChildren:0, parent:s} and equals to child sprite",
				behaviour : function():*{
					var s : Sprite = new Sprite();
					var s1 : Sprite = new Sprite();
					s.addChild(s1);
					return new Duck({_type_:Sprite, numChildren:0, parent:s}).equals(s1);
				},
				shouldEqual : true
			},
			{
				description : "Duck is {_type_:Sprite, listeners:[listener]} throws exception because listeners is a private field",
				behaviour : function():*{
					var s : Sprite = new Sprite();
					s.addEventListener(Event.ACTIVATE, listener);
					return new Duck({_type_:Sprite, listeners:[listener]}).equals(s);
				},
				shouldThrow : Error
			}
		]
	};
}


import flash.events.Event;
function listener(event : Event) : void {
}